<?php include("head.php");
if(isset($_POST['Submit']))
{	

if(isset($_SESSION['adminId']))
	{

		$dbres = mysql_query("SELECT * FROM ".ADMIN."  WHERE adminId='".$_SESSION['adminId']."'");
		
		$Fetchpass=mysql_fetch_array($dbres);
		
		$USerNAme=$Fetchpass['adminUser'];
		
		$passw=$Fetchpass['adminPass'];
		
		$CurPass=$_POST['cpass'];
		
		$CurPassMd5=md5($CurPass);
		
		$ChangePass=$_POST['password1'];
		
		$ChangePassMd5=md5($ChangePass);

if($_POST['password1']!=$_POST['rpass'])

		{
		
		$_SESSION['ChangeMsg']='Retype Password does\'t match';	
		
		echo "<script>window.location='".$_SERVER['PHP_SELF']."'</script>";
		
		die();
		
		}

if($passw==$CurPassMd5)

	{
	
		if(isset($_POST['password1'])) 
	
			{
		
		
				$sql_query_email=mysql_query("SELECT * FROM ".GLOBALSETTINGS); 
		
				$fetch_array=mysql_fetch_array($sql_query_email);		
		
				$charset  = 'MIME-Version: 1.0' . "\r\n";
		
				$charset .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		
				$message = "Changing Information About Admin Section(Dailypicks)"."<br><br>
		
				Your Username is     : ".$USerNAme."<br><br>
				Your new Password is : ".$ChangePass;
				$subject = "Your Change information of AdMobWeb";
				@mail($fetch_array['adminEmail'], $subject, $message,$charset); 
		
				mysql_query("UPDATE ".ADMIN." SET adminPass='".$ChangePassMd5."' WHERE adminId='".$_SESSION['adminId']."'");
				
				$_SESSION['ChangeMsg']='Password Changed Successfully';	
				
				echo "<script>window.location='".$_SERVER['PHP_SELF']."'</script>";
				
				die();
		
		
		
			}
			else
	
				{
		
					$_SESSION['ChangeMsg']='The given Password is not valid';
					echo "<script>window.location='".$_SERVER['PHP_SELF']."'</script>";
					die();
		
				}
	
	}

		else

		{
		
		$_SESSION['ChangeMsg']='The given Password is not valid';
		echo "<script>window.location='".$_SERVER['PHP_SELF']."'</script>";
		die();
		
		}	



	}



}



?>







<script type="text/javascript">







function valid()



{



if(document.form1.cpass.value=="")



{



alert("Current password field is blank");



document.form1.cpass.focus();



return false;



}



if(document.form1.password1.value=="")



{



alert("Enter password field is blank");



document.form1.password1.focus();



return false;



}



if(document.form1.rpass.value=="")



{



alert("Retype password field is blank");

document.form1.rpass.focus();

return false;

}

if(document.form1.password1.value!=document.from1.rpass.value)

{

alert("Password does not match");

document.from1.password1.focus();

return false;

}



}



</script>

<fieldset>



	<legend class="LEGEND">Change Password</legend>



<table width="100%" border="0" cellpadding="5" cellspacing="0" height="238">



<tr> 



<td height="30" align="center"  style="color:#000000;font-size:12px;padding-left:20; "><p><strong>EDIT 



PASSWORD</strong></p></td></td>



</tr>



<tr> 



<td align="center" height="31"> <form name="form1" action="" method="post" onsubmit="return valid();">



	<table width="100%" border="0" cellspacing="2" cellpadding="0">



	<tr>

	<td>&nbsp;</td>

	<td>&nbsp;</td>

	<td colspan="2" align="center"><div align="left"></div></td>

	</tr>

		<?php if(isset($_SESSION['ChangeMsg']))

		{?>

	<tr>

	

	<td height="27" colspan="4" align="center"><font color="#FF0000"><?php echo $_SESSION['ChangeMsg'];?></font></td>

	</tr>

		<?php } ?>

	<tr> 



	<td width="193">&nbsp;</td>



	<td width="204" style="color:#000000;font-size:12px;" align="left">Give Your Current Password</td>

	<td width="32" align="center">::</td>

	<td width="521"><input name="cpass" type="password" size="30" id="cpass"></td>

	</tr>



	<tr>



	<td>&nbsp;</td>



	<td style="color:#000000;font-size:12px;padding-left:0; " align="left">Enter New Password</td>

	<td align="center">::</td>

	<td><input name="password1" type="password" id="password1" size="30"></td>

	</tr>





	<tr> 



	<td>&nbsp;</td>



	<td style="color:#000000;font-size:12px;padding-left:0; " align="left">Retype New password</td>

	<td align="center">::</td>

	<td><input name="rpass" id="rpass" type="password" size="30"></td>

	</tr>



	<tr align="center">



	<td>&nbsp;</td>



	<td>&nbsp;</td>

	<td>&nbsp;</td>

	<td>&nbsp;</td>

	</tr>



	<tr align="center"> 



	<td>&nbsp; </td>



	<td>&nbsp;</td>

	<td>&nbsp;</td>

	<td> <input type="submit" name="Submit" value="Change Password" style="float: left"></td>

	</tr>

	</table>



		



</form></td>



</tr>



<tr> 



<td height="25">&nbsp;</td>



</tr>



<tr> 



<td align="center" height="19">&nbsp;</td>



</tr>



</table></fieldset>



<?php

$_SESSION['ChangeMsg']='';

	include("foot.php");


?>

